<template>
  <div class="home">

  </div>
</template>

<script>
// @ is an alias to /src

import axios from 'axios'

export default {
  name: 'axios3-5',
  components: {

  },
  created () {
    let source = axios.CancelToken.source()
    axios.get('/data.json', {
      cancelToken: source.token
    }).then(res => {
      console.log(res)
    }).catch(err => {
      console.log(err)
    })
    //取消请求(message可选)
    source.cancel('cancle http')
    //什么情况用到取消请求

  },
}
</script>
